import django_filters
from apps.user.models import *


class UserFilter(django_filters.rest_framework.FilterSet):
    """ 过滤类 """

    minAge = django_filters.NumberFilter(field_name='age', help_text="最小年龄", lookup_expr='gte')
    maxAge = django_filters.NumberFilter(field_name='age', help_text="最大年龄", lookup_expr='lte')
    minHeight = django_filters.NumberFilter(field_name='height', help_text="最小身高", lookup_expr='gte')
    maxHeight = django_filters.NumberFilter(field_name='height', help_text="最大身高", lookup_expr='lte')
    nickname = django_filters.CharFilter(lookup_expr='icontains')
    username = django_filters.CharFilter(lookup_expr='icontains')
    phone = django_filters.CharFilter(lookup_expr='icontains')
    parent__code = django_filters.CharFilter(field_name='parent__code')

    # tag = django_filters.CharFilter(lookup_expr='in')

    class Meta:
        model = UserModel
        fieldList = ['id', 'code', 'phone', 'username', 'nickname', 'realname', 'city', 'checkStatus',
                     'gender', 'status', 'rank', 'team', 'identity']
        extraList = ['minVip', 'minRank']
        fields = fieldList
